package cn.wolfcode.service.impl;


import cn.wolfcode.domain.Employee;
import cn.wolfcode.mapper.EmployeeMapper;
import cn.wolfcode.query.EmployeeQuery;
import cn.wolfcode.service.IEmployeeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.security.AlgorithmParameterGenerator;

/**
 *
 * 员工业务层接口实现类
 * 1>自定义类继承ServiceImpl
 * 2>明确指定2个泛型: 1>要依赖的持久层Mapper接口:EmployeeMapper  2>操作实体对象: Employee
 * 3>实现自定义业务层接口:IEmployeeService
 *
 **/
@Service
@Transactional
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements IEmployeeService {
    //自定义业务方法
    @Override
    public Employee queryByQo() {
        return null;
    }


    @Override
    public Page<Employee> queryPage(EmployeeQuery qo) {

        Page<Employee> page = new Page<>(qo.getCurrentPage(), qo.getPageSize());
        QueryWrapper<Employee> wrapper = new QueryWrapper<>();
        wrapper.like(StringUtils.hasLength(qo.getKeyword()), "name", qo.getKeyword());

        return  super.page(page, wrapper);
    }
}
